package com.ruoyi.common.core.utils.exptimpt;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author huangliang
 * @date 2024-09-04 17:16
 * @description 导入导出抽象策略类
 */
@Getter
@Setter
public abstract class AbstractExImportStrategy<T> {

    public final ExcelUtil<T> util;

    public final IExImportEnum exImportEnum;

    public final ExImportHandlerChain importHandlerChain;

    public final ExImportHandlerChain exportHandlerChain;

    public List<T> dataList;

    protected AbstractExImportStrategy(ExcelUtil<T> util, IExImportEnum exImportEnum, ExImportHandlerChain importHandlerChain, ExImportHandlerChain exportHandlerChain) {
        this.util = util;
        this.exImportEnum = exImportEnum;
        this.importHandlerChain = importHandlerChain;
        this.exportHandlerChain = exportHandlerChain;
    }

    /**
     * 插入数据
     * @return 插入数据条数
     */
    public abstract Integer insertData();

    /**
     * 导入的业务校验（有业务校验的重写）
     */
    public void businessVerificationForImport(List<T> dataList) {
        //nothing to do
    }
}
